﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FB.Bussiness;
using FB.DataAccess;

namespace FB.Videos.ucCommon
{
    public partial class ucVideoInCategory : System.Web.UI.UserControl
    {
        /// <summary>
        ///  View State CategoryID
        /// </summary>
        public Guid? CategoryID
        {
            get
            {
                object obj = this.ViewState["_CateID"];
                if (obj == null)
                    return null; //default to show ID : 0 
                else
                    return (Guid)obj;
            }
            set
            {
                this.ViewState["_CateID"] = value;
            }

        }
        /// <summary>
        ///  Limit number to display
        /// </summary>
        public int Limit
        {
            get
            {
                object obj = this.ViewState["_Limit"];
                if (obj == null)
                    return 0; //default to show ID : 0 
                else
                    return (int)obj;
            }
            set
            {
                this.ViewState["_Limit"] = value;
            }

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            VideoCategoryBO CateBO = new VideoCategoryBO();
            VideoCategory CateEnt = CateBO.GetVideoCategoryById((Guid)CategoryID);
            lblCateTitle.Text = CateEnt.Name;
            VideoBO BO = new VideoBO();
            rptData.DataSource = BO.GetVideoByCategory((Guid)CategoryID, Limit);
            rptData.DataBind();
        }
    }
}